import { createHashRouter, Navigate } from "react-router-dom";
import Login from "../pages/login";
import HOC from "./HOC";
import Loading from "../components/loading";
import { Suspense, lazy } from "react";

const Home = lazy(() => import("../pages/home"));

const Main = lazy(() => import("../pages/home/main"));
const Alter = lazy(() => import("../pages/home/alter"));
const VdData = lazy(() => import("../pages/home/vdData"));
const EqAdmin = lazy(() => import("../pages/home/eqAdmin"));
const UserWM = lazy(() => import("../pages/home/userWM"));

const router = createHashRouter([
  {
    path: "/",
    element: <Navigate to="/login" />,
  },
  {
    path: "/login",
    element: <Login />,
  },
  {
    path: "/home",
    element: <Home />,
    children: [
      {
        path: "",
        // element: <HOC href="/home/main" />,
        element: (
          <Suspense fallback={<Loading />}>
            <Main />
          </Suspense>
        ),
      },
      {
        path: "alter",
        // element: <HOC href="/home/alter" />,
        element: (
          <Suspense fallback={<Loading />}>
            <Alter />
          </Suspense>
        ),
      },
      {
        path: "vdData",
        // element: <HOC href="/home/vdData" />,
        element: (
          <Suspense fallback={<Loading />}>
            <VdData />
          </Suspense>
        ),
      },
      {
        path: "eqAdmin",
        // element: <HOC href="/home/alter" />,
        element: (
          <Suspense fallback={<Loading />}>
            <EqAdmin />
          </Suspense>
        ),
      },
      {
        path: "userWM",
        // element: <HOC href="/home/alter" />,
        element: (
          <Suspense fallback={<Loading />}>
            <UserWM />
          </Suspense>
        ),
      },
    ],
  },
  {
    path: "*",
    element: <div>路径错误404</div>,
  },
]);
export default router;
